Skip to content

GH-2247 - Add repository initialization metrics. #2273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from

Conversation

christophstrobl
Copy link
Member

Add support for collecting data repository startup metrics using core framework ApplicationStartup and StartupStep.
Collected metrics can be stored with Java Flight Recorder when using a FlightRecorderApplicationStartup or exposed via Spring Boot startup Actuator endpoint http POST :/actuator/startup

Metrics are collected under spring.data.repository and contain the overall init time, as well as information about post processing, metadata collection, etc.
Specifics about the number of repository fragments or the repository interface type are provided via tags as shown in the snippet below.

{
  "startupStep": {
    "name": "spring.data.repository.init",
    "id": 120,
    "parentId": 98,
    "tags": [
      {
        "key": "repository",
        "value": "com.example.demo.PersonRepo"
      }
    ]
  },
  "startTime": "2021-01-14T12:31:45.461911319Z",
  "endTime": "2021-01-14T12:31:45.481086739Z",
  "duration": "PT0.01917542S"
}

Closes #2247

@mp911de
Copy link
Member

mp911de commented Jan 18, 2021

Here's a screenshot from the flight recorder regarding the startup steps:

Bildschirmfoto 2021-01-18 um 10 58 46

@mp911de mp911de self-assigned this Jan 28, 2021
christophstrobl and others added 6 commits January 28, 2021 14:34
This commit adds initial support for collecting data repository startup metrics using core framework ApplicationStartup and StartupStep.
Collected metrics can be stored with Java Flight Recorder when using a FlightRecorderApplicationStartup.
Adds a StartupStep for the creation of the target SD module Repository object (e.g. SD JPA). This could vary significantly from 1 SD module to another.

Adds a StartupStep for the creation of the SD Repository Proxy.

Renames the StartupStep wrapping the Repository composition logic to 'spring.data.repository.composition'.

Moves the construction/initialization of the ApplicationStartup instance after the assertions in the getRepository(..) method.
Add the interface type name the repository is created for, query executors, as well as the number of fragments and measurements about potential post processors.
This commit adds application startup metrics for the time taken to scan the context for Spring Data repositories on a per module (JPA, MongoDB,...) base.
We capture the module name, the scan base package and the number of repositories found.

{
  "startupStep": {
    "name": "spring.data.repository.scanning",
    "id": ...,
    "parentId": ...,
    "tags": [
      {
        "key": "data-module",
        "value": "MongoDB"
      },
      {
        "key": "packages",
        "value": "com.example.demo"
      },
      {
        "key": "repository.count",
        "value": "1"
      }
    ]
  }
}
Make spring.data.repository.postprocessors conditional to reduce the number of events. Append full fragment diagnostics.
@mp911de mp911de force-pushed the issue/DATACMNS-1832 branch from 42be28e to 579ca77 Compare January 28, 2021 13:49
@mp911de
Copy link
Member

mp911de commented Jan 28, 2021

Bildschirmfoto 2021-01-28 um 14 49 03

@mp911de
Copy link
Member

mp911de commented Jan 28, 2021

Rebased and force-pushed.

Reorder methods
Reorder methods, add author tag, reformat code.
mp911de pushed a commit that referenced this pull request Jan 28, 2021
This commit adds support for collecting data repository startup metric (repository scanning, repository initialization) using core framework ApplicationStartup and StartupStep.
Collected metrics can be stored with Java Flight Recorder when using a FlightRecorderApplicationStartup.

Closes #2247.
Original pull request: #2273.
mp911de added a commit that referenced this pull request Jan 28, 2021
Attach repository interface name to each repository init event.

Make spring.data.repository.postprocessors conditional to reduce the number of events. Append full fragment diagnostics.

Reorder methods, add author tag, reformat code.

Closes #2247.
Original pull request: #2273.
@mp911de
Copy link
Member

mp911de commented Jan 28, 2021

That's merged and polished now.

@mp911de mp911de closed this Jan 28, 2021
@mp911de mp911de deleted the issue/DATACMNS-1832 branch January 28, 2021 14:06
@mp911de mp911de added this to the 2.5 M3 (2021.0.0) milestone Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instrument repository creation for ApplicationStartup metrics [DATACMNS-1832]
3 participants